#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 11:08:21 2013

@author: Sat Kumar Tomer
@email: satkumartomer@gmail.com
@website: www.ambhas.com
"""


import numpy as np
from ambhas.interpolation import idw
import matplotlib.pyplot as plt
import os

# outfile paths
image_idw_rain = '../images/rain_idw.png'

# convert relative path into absolute 
cur_dir = os.path.dirname(__file__)
image_idw_rain = os.path.join(cur_dir, image_idw_rain)

# generate some synthetic data
x = np.random.random(5) 
y = np.random.random(5)
X = np.linspace(0, 1, 20)
Y = np.linspace(0, 1, 20)
rain = np.random.random(5)

# interpolate using thiessen polygon
data = idw(x, y, rain, X, Y)

# plot the interpolated data
plt.clf()
plt.pcolor(X,Y,data, vmin=0, vmax=1)
plt.plot(x,y, '*')
plt.xlabel('X')
plt.ylabel('Y')
plt.colorbar()
plt.savefig(image_idw_rain)
plt.close()


